import request from '../utils/request'

export function getPermissionTree () {
  return request({
    url: '/permission/tree',
    method: 'get'
  })
}

export function getPermissionList () {
  return request({
    url: '/permission/list',
    method: 'get'
  })
}

export function getPermission (permissionId) {
  return request({
    url: `/permission/${permissionId}`,
    method: 'get'
  })
}

export function insertPermission (permission) {
  return request({
    url: '/permission',
    method: 'POST',
    data: permission
  })
}

export function deletePermission (permission) {
  return request({
    url: '/permission/delete',
    method: 'delete',
    data: permission
  })
}

export function resetPermission (permission) {
  return request({
    url: '/permission/reset',
    method: 'delete',
    data: permission
  })
}

export function updatePermission (permission) {
  return request({
    url: '/permission',
    method: 'put',
    data: permission
  })
}

export function getPermissionByRoleId (roleId) {
  return request({
    url: `/permission/role/${roleId}`,
    method: 'get'
  })
}

export function deleteRolePermission (data) {
  return request({
    url: '/permission/role/',
    method: 'delete',
    data: data
  })
}

export function insertRolePermission (data) {
  return request({
    url: '/permission/role/',
    method: 'post',
    data: data
  })
}
